#include  <cstdio>
#include  <cstring>

int main(int argc, char *argv[])
{
	int n,q,m,d[105],temp,index;
	while( scanf("%d%d",&n,&q) && n != 0 )
	{
		memset(d,0,105*4);
		for(int j = 0; j < n; ++j)
		{
			scanf("%d",&m);
			for( int i = 0; i < m ; ++i )
			{
				scanf("%d",&temp);
				d[temp]++;
			}
		}
		int max = 0;
		for( int i = 1; i <= 100 ; ++i )
		{
			if(d[i] > max)
			{
				max = d[i];
				index = i;
			}
		}
		if(max >= q)
			printf("%d\n",index);
		else
			printf("0\n");
		
	}
}
